package combat.settlement;

import combat.settlement.calculate.DiscountFactory;
import combat.settlement.calculate.DiscountStrategy;
import combat.settlement.order.Order;
import combat.settlement.order.decorators.FreeShippingDecorator;
import combat.settlement.order.decorators.RewardPointsDecorator;

/**
 * @author Seon
 * @version 1.0
 * @since 2024-09-03
 */
public class SettlementClient {
    public static void main(String[] args) {
        // 创建订单
        Order order = new Order(300);

        DiscountStrategy discount = DiscountFactory.createDiscountStrategy("PercentageDiscount");
        order.setDiscountStrategy(discount);

        // 计算折扣后的价格
        double finalPrice = order.calculateFinalPrice();
        System.out.println("Price after discount : " + finalPrice);

        // 进行订单后处理
        order = new FreeShippingDecorator(order);
        order = new RewardPointsDecorator(order);
        order = new RewardPointsDecorator(order);

        double priceWithFeature = order.calculateFinalPrice();
        System.out.println("Price after discount with all features : " + priceWithFeature);
    }
}
